<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>部门管理</title>
	<link href="/asset/css/admin.css" rel="stylesheet" />
	<link rel="stylesheet" href="/asset/module/dTree/font/dtreefont.css"/>
	<link rel="stylesheet" href="/asset/module/dTree/dtree.css"/>
	<style id='panda-theme-color'></style>
</head>
<body  class="theme-panda">
	<div class="layui-card" hidden>
		<div class="layui-card-body">
			<form class="layui-form" action="">
				<div class="layui-form-item">
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">用户名</label>
						<div class="layui-input-inline">
							<input type="text" name="realName" placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">性别</label>
						<div class="layui-input-inline">
							<input type="text" name="realName" placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">邮箱</label>
						<div class="layui-input-inline">
							<input type="text" name="realName" placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<button class="layui-btn layui-btn-md layui-btn-primary" lay-submit lay-filter="user-query">
							<i class="layui-icon layui-icon-search"></i>
							查询
						</button>
						<button type="reset" class="layui-btn layui-btn-md">
							<i class="layui-icon layui-icon-refresh"></i>
							重置
						</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md3">
			<div class="layui-card">
				<div class="layui-card-body">
					<div id="organizationTreeContent" style="overflow: auto">
						<ul id="treeList" class="dtree"></ul>
					</div>
				</div>
			</div>
		</div>
		<div class="layui-col-md9">
			<div class="layui-card">
				<div class="layui-card-body">
					<table id="tableList" lay-filter="tableList"></table>
				</div>
			</div>
		</div>
	</div>

	<script type="text/html" id="tableToolBar">
		<button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="add">
			<i class="layui-icon layui-icon-add-1"></i>新增部门
		</button>
		<button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">
			<i class="layui-icon layui-icon-delete"></i>编辑部门
		</button>
		<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="batchRemove">
			<i class="layui-icon layui-icon-delete"></i>批量删除
		</button>
	</script>

	<script type="text/html" id="toolBar">
		<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit"><i
			class="layui-icon layui-icon-edit"></i>编辑</button>
		<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i
			class="layui-icon layui-icon-delete"></i>删除</button>
	</script>
<!-- 引入脚部 -->
<script src="/asset/layui/layui.js?v=1.0.0"></script>
<script src="/asset/js/common.js?v=1.0.0"></script>
<script>
	layui.use(['func','table','com','layer','jquery','dtree'], function() {
        var func = layui.func, layer = layui.layer, dtree = layui.dtree,$ = layui.jquery;
        var table = layui.table;
        var common = layui.com;
		var pid = 1;
        var cols = [
				{type: 'checkbox'},
				{title: 'ID',field: 'id',align: 'center'},
				{title: '名称',field: 'name',align: 'center'},
				{title: '负责人',field: 'leader',align: 'center'},
				{title: '联系方式',field: 'mobile',align: 'center'},
				{title: '操作',toolbar: '#toolBar',align: 'center',width: 150}];

        //【渲染TABLE】
		func.tableIns(cols,"tableList",null,"list?type=2",'#tableToolBar');
        func.dtreeIns("treeList", "tableList",function (data) {
			pid = data;
        });
        //【设置弹框】
        func.setWin("系统部门",900, 520);
		// 本页面 重新定义事件
        table.on("toolbar(tableList)", function(obj){
            var checkStatus = table.checkStatus("tableList");
            if(obj.event=="add"){   //添加
                if(pid == 0){
                    layer.msg("请选中一项左侧部门");
                }else{
                    common.edit("部门",0,900, 520,{'pid':pid});
                }
            }else if(obj.event=="batchRemove"){
                var data= {};
                data.title = "批量删除";
                data.url =  cUrl + "/batchDelete";
                data.data = checkStatus.data;
                data.confirm =  true;
                data.type =  'GET';
                common.batchFunc(data, (function() {
                    table.reload('tableList');
                }));
            }else if(obj.event=="edit"){
                if(pid == 0){
                    layer.msg("请选中一项左侧部门");
				}else{
                    common.edit("部门",pid,900,520);
				}
			}
        });

        $(window).resize(function() {
            //获取太频繁了 //
            //dtree.reload("treeList");
        });



    })
</script>
</body>
</html>
